package com.kaiyiweitong.tongxing.util;

/**
 * Created by Administrator on 2017/9/1 0001.
 */

import android.content.Context;
import android.content.SharedPreferences;

import com.kaiyiweitong.tongxing.constant.LogicConstant;

/**
 * SharedPreferences文件存储帮助类
 *
 * @author stefan
 */
public class SpUtils {
    private static SharedPreferences mSp = null;
    private static SharedPreferences.Editor mEdit = null;

    public static void saveString(Context context, String key, String text) {
        if (mSp == null) {
            mSp = context.getSharedPreferences(LogicConstant.SP_FILENAME, Context.MODE_PRIVATE);
        }
        if (mEdit == null) {
            mEdit = mSp.edit();
        }
        mEdit.putString(key, text);
        mEdit.commit();
    }

    public static String getString(Context context, String key) {
        if (mSp == null) {
            mSp = context.getSharedPreferences(LogicConstant.SP_FILENAME, Context.MODE_PRIVATE);
        }
        return mSp.getString(key, "");
    }
}